home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Farbe0.cpp < prev    next >
C/C++ Source or Header  |  1999-01-06  |  2KB  |  50 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Farbe0.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. const int FMax = 16;
  10. TColor Farbe[FMax] =
  11.   {clBlack, clMaroon, clGreen, clNavy, clTeal, clPurple,
  12.    clOlive, clGray, clSilver, clRed, clLime, clBlue,
  13.    clAqua, clFuchsia, clYellow, clWhite};
  14. String FarbName[FMax] =
  15.   {"Black", "Maroon", "Green", "Navy", "Teal", "Purple",
  16.    "Olive", "Gray", "Silver", "Red", "Lime", "Blue",
  17.    "Aqua", "Fuchsia", "Yellow", "White"};
  18.  
  19. TForm1 *Form1;
  20. //---------------------------------------------------------------------------
  21. __fastcall TForm1::TForm1(TComponent* Owner)
  22.     : TForm(Owner)
  23. {
  24. }
  25. //---------------------------------------------------------------------------
  26. void __fastcall TForm1::Button1Click(TObject *Sender)
  27. {
  28.   for (int i=0; i<FMax/2; i++)
  29.   {
  30.     Canvas->Brush->Color = clBtnFace;
  31.     Canvas->TextOut (20,i*20+30,FarbName[i]);
  32.     Canvas->TextOut (80,i*20+30,String(Farbe[i]));
  33.     Canvas->Brush->Color = Farbe[i];
  34.     Canvas->TextOut (150,i*20+30, "        ");
  35.   }
  36.   for (int i=FMax/2; i<FMax; i++)
  37.   {
  38.     Canvas->Brush->Color = clBtnFace;
  39.     Canvas->TextOut (ClientWidth/2+30,(i-FMax/2)*20+30,FarbName[i]);
  40.     Canvas->TextOut (ClientWidth/2+90,(i-FMax/2)*20+30,String(Farbe[i]));
  41.     Canvas->Brush->Color = Farbe[i];
  42.     Canvas->TextOut (ClientWidth/2+160,(i-FMax/2)*20+30, "        ");
  43.   }
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TForm1::FormCreate(TObject *Sender)
  47. {
  48.   randomize ();
  49. }
  50. //---------------------------------------------------------------------------